package com.site.web.controller.war;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.site.common.annotation.Log;
import com.site.common.core.controller.BaseController;
import com.site.common.core.domain.AjaxResult;
import com.site.common.enums.BusinessType;
import com.site.war.domain.SiteInspect;
import com.site.war.service.ISiteInspectService;
import com.site.common.utils.poi.ExcelUtil;
import com.site.common.core.page.TableDataInfo;

/**
 * 检验书管理
Controller
 *
 * @author site
 * @date 2023-10-16
 */
@RestController
@RequestMapping("/war/inspect")
public class SiteInspectController extends BaseController
{
    @Autowired
    private ISiteInspectService siteInspectService;

    /**
     * 查询检验书管理列表
     */
//    @PreAuthorize("@ss.hasPermi('war:inspect:list')")
    @GetMapping("/list")
    public TableDataInfo list(SiteInspect siteInspect)
    {
        startPage();
        List<SiteInspect> list = siteInspectService.selectSiteInspectList(siteInspect);
        return getDataTable(list);
    }

    /**
     * 导出检验书管理列表
     */
    @PreAuthorize("@ss.hasPermi('war:inspect:export')")
    @Log(title = "检验书管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SiteInspect siteInspect)
    {
        List<SiteInspect> list = siteInspectService.selectSiteInspectList(siteInspect);
        ExcelUtil<SiteInspect> util = new ExcelUtil<SiteInspect>(SiteInspect.class);
        util.exportExcel(response, list, "检验书管理数据");
    }

    /**
     * 获取检验书管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('war:inspect:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(siteInspectService.selectSiteInspectById(id));
    }

    /**
     * 新增检验书管理
     */
//    @PreAuthorize("@ss.hasPermi('war:inspect:add')")
    @Log(title = "检验书管理 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SiteInspect siteInspect)
    {
        return toAjax(siteInspectService.insertSiteInspect(siteInspect));
    }

    /**
     * 修改检验书管理
     */
    @PreAuthorize("@ss.hasPermi('war:inspect:edit')")
    @Log(title = "检验书管理 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SiteInspect siteInspect)
    {
        return toAjax(siteInspectService.updateSiteInspect(siteInspect));
    }

    /**
     * 删除检验书管理
     */
    @PreAuthorize("@ss.hasPermi('war:inspect:remove')")
    @Log(title = "检验书管理 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(siteInspectService.deleteSiteInspectByIds(ids));
    }
}
